package com.originskyseed.platform.user.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.originskyseed.platform.user.model.OrgGovernment;

/**
 * 行政区划表Mapper类（OSI_USER_ORG）
 *
 * @author LiChengHuan
 */
public interface OrgGovernmentMapper {

	/**
	 * 根据区域code查出关联的行政区列表
	 *
	 * @param areaId
	 * @return
	 * @throws Exception
	 */
	public List<OrgGovernment> selectByAreaId(@Param("areaId") String areaId) throws Exception;

	/**
	 * 删除记录
	 *
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public int deleteByPrimaryKey(String id) throws Exception;

	/**
	 * 批量删除记录
	 *
	 * @param ids
	 * @return
	 * @throws Exception
	 */
	public int deleteByPrimaryKeys(List<String> ids) throws Exception;

	/**
	 * 插入记录
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int insert(OrgGovernment record) throws Exception;

	/**
	 * 插入记录（仅非空值字段）
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int insertSelective(OrgGovernment record) throws Exception;

	/**
	 * 更新记录
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int updateByPrimaryKey(OrgGovernment record) throws Exception;

	/**
	 * 更新记录（仅非空值字段）
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int updateByPrimaryKeySelective(OrgGovernment record) throws Exception;

	/**
	 * 查询记录
	 *
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public OrgGovernment selectByPrimaryKey(String id) throws Exception;

	/**
	 * 查询列表
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public List<OrgGovernment> selectList(OrgGovernment record) throws Exception;

	/**
	 * 查询列表
	 *
	 * @param countryCode
	 * @return
	 * @throws Exception
	 */
	public List<OrgGovernment> selectListByCountryCode(String countryCode) throws Exception;

	/**
	 * 分页查询列表
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public List<OrgGovernment> selectListByPage(Map<String, Object> params) throws Exception;

	/**
	 * 获取全部行政区划
	 *
	 * @return
	 * @throws Exception
	 */
	public List<OrgGovernment> selectAllUserOrg() throws Exception;

	/**
	 * 删除前判断是否存在下级
	 *
	 * @param OrgGovernment
	 * @return
	 * @throws Exception
	 */
	public Boolean selectExitChild(OrgGovernment OrgGovernment) throws Exception;

	/**
	 * 批量更新区域信息
	 *
	 * @param list
	 * @return
	 * @throws Exception
	 */
	public int insertGovernmentList(List<OrgGovernment> list) throws Exception;

	/**
	 * 根据子账号查询母账号部门(传入母帐号则返回母账号信息)
	 *
	 * @param sonAccount
	 * @return
	 * @throws Exception
	 */
	OrgGovernment selectParentAccountOrg(String sonAccount);

	/**
	 * 判断编码是否存在
	 *
	 * @param orgGovernment
	 * @return
	 * @throws Exception
	 */
	public Boolean existCode(OrgGovernment orgGovernment) throws Exception;

	/**
	 * 查询树，根据父code
	 *
	 * @param orgGovernment
	 * @return
	 * @throws Exception
	 */
	public List<OrgGovernment> selectTreeByParentCode(OrgGovernment orgGovernment) throws Exception;

	/**
	 * 批量更新行政区划
	 *
	 * @param list
	 * @return
	 * @throws Exception
	 */
	public int updateOrgGovernmentList(List<OrgGovernment> list) throws Exception;

	/**
	 * 根据编号删除行政区划
	 *
	 * @param list code集合
	 * @return
	 * @throws Exception
	 */
	public int deleteOrgGovernmentListByCode(List<String> list) throws Exception;

	/**
	 * 根据编码查询行政区域
	 *
	 * @param list code 集合
	 * @return
	 * @throws Exception
	 */
	List<String> selectExistCodeListByCodeList(List<String> list) throws Exception;

	/**
	 * 删除所有的地址信息
	 *
	 * @return
	 * @throws Exception
	 */
	int deleteAllAddress() throws Exception;

	/**
	 * 查询记录总数
	 *
	 * @return
	 * @throws Exception
	 */
	int selectCount() throws Exception;

	/**
	 * 删除指定数目的数据
	 *
	 * @param deleteCount
	 * @return
	 */
	int deleteByNum(@Param("deleteCount") int deleteCount);

	/**
	 * 根据CODE查询对应的NAME
	 * 
	 * @param code
	 * @return
	 */
	String selectNameByCode(String code);
}